import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class DismissibleDemo extends StatelessWidget {
  List<String> items = new List<String>.generate(30, (i) => "列表项${i + 1}");

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Dismissible"),
        centerTitle: true,
      ),
      body: ListView.builder(itemBuilder: (context, index) {
        final item = items[index];
        return Dismissible(
            key: Key(item),
            child: ListTile(
              title: Text(item),
            ),
          onDismissed: (direction){
              items.removeAt(index);
              Scaffold.of(context).showSnackBar(SnackBar(content: Text('$item 被删除了')));
          },
        );
      }),
    );
  }

}